{"ast":null,"code":"import _slicedToArray from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";import React from'react';import{Context}from\"../../../index\";import{useForm,Controller,useFormState}from'react-hook-form';import Typography from'@mui/material/Typography';import TextField from'@mui/material/TextField';import Button from\"../../../components/Button\";import MailOutlineIcon from'@mui/icons-material/MailOutline';import VpnKeyOutlinedIcon from'@mui/icons-material/VpnKeyOutlined';import{emailValidation,passwordValidation}from'../../validation';import styles from'../../Form.module.scss';import{jsx as _jsx}from\"react/jsx-runtime\";import{jsxs as _jsxs}from\"react/jsx-runtime\";var LoginForm=function LoginForm(updateData){var _React$useContext=React.useContext(Context),store=_React$useContext.store;var _useForm=useForm(),handleSubmit=_useForm.handleSubmit,control=_useForm.control;var _useFormState=useFormState({control:control}),errors=_useFormState.errors;var _React$useState=React.useState({registration:'registration',forgot:'forgot'}),_React$useState2=_slicedToArray(_React$useState,1),data=_React$useState2[0];var onSubmit=function onSubmit(data){store.setIsError(false);store.signIn(data);};return/*#__PURE__*/_jsxs(\"div\",{className:styles.authForm,children:[/*#__PURE__*/_jsx(Typography,{variant:\"h4\",component:\"div\",className:styles.authFormTitle,children:\"\\u0412\\u043E\\u0439\\u0434\\u0438\\u0442\\u0435\"}),/*#__PURE__*/_jsx(Typography,{variant:\"subtitle1\",gutterBottom:true,component:\"div\",className:styles.authFormSubtitle,children:\"\\u0427\\u0442\\u043E\\u0431\\u044B \\u043F\\u043E\\u043B\\u0443\\u0447\\u0438\\u0442\\u044C \\u0434\\u043E\\u0441\\u0442\\u0443\\u043F\"}),/*#__PURE__*/_jsxs(\"form\",{className:styles.authForm__form,onSubmit:handleSubmit(onSubmit),children:[/*#__PURE__*/_jsx(Controller,{control:control,name:\"username\",rules:emailValidation,render:function render(_ref){var _errors$username,_errors$username2;var field=_ref.field;return/*#__PURE__*/_jsx(TextField,{label:\"\\u042D\\u043B. \\u0430\\u0434\\u0440\\u0435\\u0441\",InputProps:{endAdornment:/*#__PURE__*/_jsx(MailOutlineIcon,{className:styles.formIcon})},onChange:function onChange(e){return field.onChange(e);},value:field.value||'',fullWidth:true,size:\"small\",margin:\"normal\",type:\"email\",error:!!((_errors$username=errors.username)!==null&&_errors$username!==void 0&&_errors$username.message),helperText:(_errors$username2=errors.username)===null||_errors$username2===void 0?void 0:_errors$username2.message});}}),/*#__PURE__*/_jsx(Controller,{control:control,name:\"password\",rules:passwordValidation,render:function render(_ref2){var _errors$password,_errors$password2;var field=_ref2.field;return/*#__PURE__*/_jsx(TextField,{label:\"\\u041F\\u0430\\u0440\\u043E\\u043B\\u044C\",InputProps:{endAdornment:/*#__PURE__*/_jsx(VpnKeyOutlinedIcon,{className:styles.formIcon})},autoComplete:\"on\",onChange:function onChange(e){return field.onChange(e);},value:field.value||'',fullWidth:true,size:\"small\",margin:\"normal\",type:\"password\",helperText:(_errors$password=errors.password)===null||_errors$password===void 0?void 0:_errors$password.message,error:!!((_errors$password2=errors.password)!==null&&_errors$password2!==void 0&&_errors$password2.message)});}}),/*#__PURE__*/_jsx(Button,{text:'Войти'})]}),/*#__PURE__*/_jsxs(\"div\",{className:styles.authForm__footer,children:[/*#__PURE__*/_jsx(Typography,{variant:\"subtitle1\",component:\"span\",className:styles.link,onClick:function onClick(){store.setIsError(false);updateData.updateData(data.registration);},children:\"\\u0417\\u0430\\u0440\\u0435\\u0433\\u0438\\u0441\\u0442\\u0440\\u0438\\u0440\\u043E\\u0432\\u0430\\u0442\\u044C\\u0441\\u044F\"}),/*#__PURE__*/_jsx(Typography,{variant:\"subtitle1\",component:\"span\",className:styles.link,onClick:function onClick(){store.setIsError(false);updateData.updateData(data.forgot);},children:\"\\u0417\\u0430\\u0431\\u044B\\u043B\\u0438 \\u043F\\u0430\\u0440\\u043E\\u043B\\u044C?\"})]})]});};export default LoginForm;","map":{"version":3,"names":["React","Context","useForm","Controller","useFormState","Typography","TextField","Button","MailOutlineIcon","VpnKeyOutlinedIcon","emailValidation","passwordValidation","styles","LoginForm","updateData","useContext","store","handleSubmit","control","errors","useState","registration","forgot","data","onSubmit","setIsError","signIn","authForm","authFormTitle","authFormSubtitle","authForm__form","field","endAdornment","formIcon","e","onChange","value","username","message","password","authForm__footer","link"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/modules/LoginForm/components/LoginForm.tsx"],"sourcesContent":["import React from 'react';\nimport {Context} from \"../../../index\";\nimport {useForm, Controller, SubmitHandler, useFormState} from 'react-hook-form';\nimport SignInRequest from \"../../../models/request/SignInRequest\";\nimport Typography from '@mui/material/Typography';\nimport TextField from '@mui/material/TextField';\nimport Button from \"../../../components/Button\";\nimport MailOutlineIcon from '@mui/icons-material/MailOutline';\nimport VpnKeyOutlinedIcon from '@mui/icons-material/VpnKeyOutlined';\nimport {emailValidation, passwordValidation} from  '../../validation';\nimport {AuthProps} from \"../../../models/props/AuthProps\";\nimport styles from '../../Form.module.scss';\n\nconst LoginForm: React.FC<AuthProps> = (updateData) => {\n    const {store} = React.useContext(Context);\n    const {handleSubmit, control} = useForm<SignInRequest>();\n    const {errors} = useFormState({control});\n    const [data] = React.useState({\n            registration: 'registration',\n            forgot: 'forgot'\n        }\n    );\n\n    const onSubmit: SubmitHandler<SignInRequest> = (data) => {\n        store.setIsError(false);\n        store.signIn(data);\n    };\n\n    return (\n        <div className={styles.authForm}>\n            <Typography variant=\"h4\" component=\"div\" className={styles.authFormTitle}>\n                Войдите\n            </Typography>\n            <Typography variant=\"subtitle1\" gutterBottom component=\"div\" className={styles.authFormSubtitle}>\n                Чтобы получить доступ\n            </Typography>\n            <form className={styles.authForm__form} onSubmit={handleSubmit(onSubmit)}>\n                <Controller\n                    control={control}\n                    name=\"username\"\n                    rules={emailValidation}\n                    render={({ field }) => (\n                        <TextField\n                            label='Эл. адрес'\n                            InputProps={{\n                                endAdornment: (\n                                <MailOutlineIcon className={styles.formIcon}/>\n                                ),\n                            }}\n                            onChange={(e) => field.onChange(e)}\n                            value={field.value || ''}\n                            fullWidth={ true }\n                            size=\"small\"\n                            margin=\"normal\"\n                            type=\"email\"\n                            error={!!errors.username?.message}\n                            helperText={errors.username?.message}\n                        />\n                    )}\n                />\n                <Controller\n                    control={control}\n                    name=\"password\"\n                    rules={passwordValidation}\n                    render={({ field }) => (\n                        <TextField\n                            label=\"Пароль\"\n                            InputProps={{\n                                endAdornment: (\n                                    <VpnKeyOutlinedIcon className={styles.formIcon}/>\n                                ),\n                            }}\n                            autoComplete=\"on\"\n                            onChange={(e) => field.onChange(e)}\n                            value={field.value || ''}\n                            fullWidth={ true }\n                            size=\"small\"\n                            margin=\"normal\"\n                            type=\"password\"\n                            helperText={errors.password?.message}\n                            error={!!errors.password?.message}\n                        />\n                    )}\n                />\n                <Button text={'Войти'} />\n            </form>\n            <div className={styles.authForm__footer}>\n                <Typography variant=\"subtitle1\" component=\"span\" className={styles.link}\n                            onClick = {() => {\n                                store.setIsError(false);\n                                updateData.updateData(data.registration);\n                            }}>\n                    Зарегистрироваться\n                </Typography>\n                <Typography variant=\"subtitle1\" component=\"span\" className={styles.link}\n                            onClick = {() => {\n                                store.setIsError(false);\n                                updateData.updateData(data.forgot);\n                            }}>\n                    Забыли пароль?\n                </Typography>\n            </div>\n        </div>\n    );\n}\n\nexport default LoginForm;"],"mappings":"8IAAA,MAAOA,MAAK,KAAM,OAAO,CACzB,OAAQC,OAAO,KAAO,gBAAgB,CACtC,OAAQC,OAAO,CAAEC,UAAU,CAAiBC,YAAY,KAAO,iBAAiB,CAEhF,MAAOC,WAAU,KAAM,0BAA0B,CACjD,MAAOC,UAAS,KAAM,yBAAyB,CAC/C,MAAOC,OAAM,KAAM,4BAA4B,CAC/C,MAAOC,gBAAe,KAAM,iCAAiC,CAC7D,MAAOC,mBAAkB,KAAM,oCAAoC,CACnE,OAAQC,eAAe,CAAEC,kBAAkB,KAAQ,kBAAkB,CAErE,MAAOC,OAAM,KAAM,wBAAwB,CAAC,wFAE5C,GAAMC,UAA8B,CAAG,QAAjCA,UAA8B,CAAIC,UAAU,CA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